home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / program / fpkpas92.zip / SRCRTL.ZIP / RTL / DOS / COLORS.PPI < prev    next >
Text File  |  1997-07-01  |  2KB  |  92 lines

  1. { COLORS.PPI }
  2.  
  3. { GetBkColor , SetBkColor , GetColor , SetColor , GetMaxColor }
  4.  
  5. function Convert(Color:longint):longint;
  6. var c,r,g,b:longint;
  7. begin
  8.   if BytesPerPixel = 1 then
  9.     begin
  10.        if (Color and $FF000000)=0 then
  11.        begin
  12.          C:=Color and $FF;
  13.          Convert:=(C shl 24) + (C shl 16) + (C shl 8) + C;
  14.        end else
  15.        begin
  16.          SetRGBPalette(((Color and $FF000000) shr 24),
  17.                        ((Color and $00FF0000) shr 16),
  18.                        ((Color and $0000FF00) shr 8),
  19.                         (Color and $000000FF));
  20.          C:=(Color and $FF000000);
  21.          Convert:=(C shr 24) + (C shr 16) + (C shr 8) + C;
  22.        end;
  23.     end else
  24.     begin
  25.        R:=(Color and $00FF0000) shr (24-VESAInfo.rm_size);
  26.        G:=(Color and $0000FF00) shr (16-VESAInfo.gm_size);
  27.        B:=(Color and $000000FF) shr (8-VESAInfo.bm_size);
  28.        C:=(R shl VESAInfo.rf_pos) or (G shl VESAInfo.gf_pos) or
  29.           (B shl VESAInfo.bf_pos);
  30.        Convert:=(C shl 16) or C;
  31.     end;
  32. end;
  33.  
  34. function GetColor : longint;
  35. begin
  36.   _graphresult:=grOk;
  37.   if not isgraphmode then
  38.     begin
  39.       _graphresult:=grNoInitGraph;
  40.       exit;
  41.     end;
  42.   getcolor:=aktcolor;
  43. end;
  44.  
  45. { ----------------------------------------------------------------------- }
  46.  
  47. procedure SetColor(color : Longint);
  48. begin
  49.   _graphresult:=grOk;
  50.   if not isgraphmode then
  51.     begin
  52.     _graphresult:=grNoInitGraph;
  53.   exit;
  54.   end;
  55.   aktcolor:=convert(Color);
  56. end;
  57.  
  58. { ----------------------------------------------------------------------- }
  59.  
  60. function GetBkColor : longint;
  61. begin
  62.   _graphresult:=grOk;
  63.   if not isgraphmode then
  64.     begin
  65.       _graphresult:=grNoInitGraph;
  66.       exit;
  67.     end;
  68.   getbkcolor:=aktbackcolor;
  69. end;
  70.  
  71. procedure SetBkColor(Color : longint);
  72. begin
  73.   _graphresult:=grOk;
  74.   if not isgraphmode then
  75.     begin
  76.       _graphresult:=grNoInitGraph;
  77.       exit;
  78.     end;
  79.   aktbackcolor:=convert(Color);
  80. end;
  81.   
  82. function  GetMaxColor : longint;
  83. begin
  84.   _graphresult:=grOk;
  85.   if not isgraphmode then
  86.     begin
  87.       _graphresult:=grNoInitGraph;;
  88.       exit;
  89.     end;
  90.   getmaxcolor:=(1 shl VESAInfo.BitsPerPixel)-1;
  91. end;
  92.